package com.jackey.rmi.server;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.jackey.rmi.service.RmiService;
import com.jackey.rmi.service.impl.RmiServiceImpl;

public class RmiServer {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			System.out.println("start rmi server");
			RmiService service = new RmiServiceImpl();
			LocateRegistry.createRegistry(9981);
			Context namingCtx = new InitialContext();  
	        //bind  
	        namingCtx.bind("rmi://10.2.9.243:9981/rmiservice", service);  
	        
	        System.out.println("start rmi server ok");
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
	}

}
